# -*- coding:utf-8 -*-

## =====================================================================
## Copyright (C) 2007-2011  Jean-Philippe GOLAY
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
## =====================================================================


from sqlobject import *
from sqlobject.sqlbuilder import *
from iVariable import Glob
import sys, os
import datetime


# Chemin vers le fichier de la base de donnee Sqlite data.db
imanage_path = str(os.getcwd())
sqlhub.processConnection = connectionForURI("sqlite:"+imanage_path+"/data/data.db")

# Definition du Modele Physique de donnees ------------------

class Country(SQLObject):
    """
	Country Object (Pays)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    code = StringCol(length=5, default=None)
    """
	@ivar: code of Country (ex. FR for France) lenght(max): 5 null
	@type v: String
    """
    name = StringCol(length=40, notNone=True)
    """
	@ivar: name of Country lenght(max): 40 not null
	@type v: String
    """
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Country not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Country default : DateTime
	@type v: DateTime
    """
    states = MultipleJoin("State")
    """
	@ivar: states of Country (relationships one Country to many State)
	@type v: Array State objects
    """
    taxs = MultipleJoin("Tax")
    """
	@ivar: taxs of Country (relationships one Country to many Tax)
	@type v: Array Tax objects
    """
    def __str__(self):
	"""
	    Methode __str__ de l object Country
	
	    @return: name of Country
	    @rtype: String
	"""
        return self.name
        
Country.createTable(ifNotExists=True)

class State(SQLObject):
    """
	State Object (Etat region)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    country = ForeignKey("Country", cascade=True)
    """
	@ivar: country of State (relationships foreignkey)
	@type v: Object Country
    """
    code = StringCol(length=5, default=None)
    """
	@ivar: code of State lenght(max): 5 null
	@type v: String
    """
    name = StringCol(length=40, notNone=True)
    """
	@ivar: name of State lenght(max): 40 not null
	@type v: String
    """
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of State not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of State default : DateTime
	@type v: DateTime
    """
    countys = MultipleJoin("County")
    """
	@ivar: countys of State (relationships One State to many County)
	@type v: Array County objects
    """
    def __str__(self):
	"""
	    Methode __str__ de l object State
	
	    @return: name + country of State
	    @rtype: String
	"""
        return self.name+"-"+str(self.country)

State.createTable(ifNotExists=True)

class County(SQLObject):
    """
	County Object (Departements)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    state = ForeignKey("State", cascade=True)
    """
	@ivar: state of County (relationships foreignkey)
	@type v: Object State
    """
    code = StringCol(length=5, default=None)
    """
	@ivar: code of County lenght(max): 5 null
	@type v: String
    """
    name = StringCol(length=40, notNone=True)
    """
	@ivar: name of County lenght(max): 40 not null
	@type v: String
    """
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of County not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of County default : DateTime
	@type v: DateTime
    """
    zipCodes = MultipleJoin("ZipCode")
    """
	@ivar: zipCodes of County (relationships On County to many ZipCode)
	@type v: Array ZipCode objects
    """
    def __str__(self):
	"""
	    Methode __str__ de l object County
	
	    @return: name + state of County
	    @rtype: String
	"""
        return self.name+"-"+str(self.state)
        
County.createTable(ifNotExists=True)

class ZipCode(SQLObject):
    """
	ZipCode Object (Code Postal)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    county = ForeignKey("County", cascade=True)
    """
	@ivar: county of ZipCode (relationships foreignkey)
	@type v: Object County
    """
    code = StringCol(length=10, notNone=True)
    """
	@ivar: code of ZipCode lenght(max): 10 not null
	@type v: String
    """
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of ZipCode not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of ZipCode default : DateTime
	@type v: DateTime
    """
    citys = MultipleJoin("City")
    """
	@ivar: citys of ZipCode (relationships One ZipeCode to many City)
	@type v: Array City objects
    """
    def __str__(self):
	"""
	    Methode __str__ de l object ZipCode
	
	    @return: code + county of ZipCode
	    @rtype: String
	"""
        return self.code+"-"+str(self.county)

ZipCode.createTable(ifNotExists=True)

class City(SQLObject):
    """
	City Object (Ville)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    zipCode = ForeignKey("ZipCode", cascade=True)
    """
	@ivar: zipCode of City (relationships foreignkey)
	@type v: Object ZipCode
    """
    code = StringCol(length=5, default=None)
    """
	@ivar: code of City lenght(max): 5 null
	@type v: String
    """
    name = StringCol(length=40, notNone=True)
    """
	@ivar: name of City lenght(max): 40 not null
	@type v: String
    """
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of City not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of City default : DateTime
	@type v: DateTime
    """
    places = MultipleJoin("Place")
    """
	@ivar: places of City (relationships One City to many Place)
	@type v: Array Place objects
    """
    persons = MultipleJoin("Person")
    """
	@ivar: persons of City (relationships One City to many Person)
	@type v: Array Person objects
    """
    def __str__(self):
	"""
	    Methode __str__ de l object City
	
	    @return: name + zipCode of City
	    @rtype: String
	"""
        return self.name+"-"+str(self.zipCode)

City.createTable(ifNotExists=True)

class Place(SQLObject):
    """
	Place Object (Etablissement)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    company = StringCol(length=100, notNone=True)
    """
	@ivar: company (name) of Place lenght(max): 100 not null
	@type v: String
    """
    address1 = StringCol(length=50, notNone=True)
    """
	@ivar: adress1 (line1) of Place lenght(max): 50 not null
	@type v: String
    """
    address2 = StringCol(length=50, notNone=False, default=None)
    """
	@ivar: adress2 (line2) of Place lenght(max): 50 null
	@type v: String
    """
    city = ForeignKey("City", cascade=False)
    """
	@ivar: city of Place (relationships foreignkey)
	@type v: Object City
    """
    tel = StringCol(length=20, notNone=False, default=None)
    """
	@ivar: tel of Place lenght(max): 20 null
	@type v: String
    """
    fax = StringCol(length=20, notNone=False, default=None)
    """
	@ivar: fax of Place lenght(max): 20 null
	@type v: String
    """
    cell = StringCol(length=20, notNone=False, default=None)
    """
	@ivar: cell of Place lenght(max): 20 null
	@type v: String
    """
    email = StringCol(length=100, notNone=False, default=None)
    """
	@ivar: email of Place lenght(max): 100 null
	@type v: String
    """
    description = StringCol(notNone=False, default=None)
    """
	@ivar: description of Place null
	@type v: String
    """
    notes = StringCol(notNone=False, default=None)
    """
	@ivar: notes of Place null
	@type v: String
    """
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Place not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Place default : DateTime
	@type v: DateTime
    """
    products = MultipleJoin("Product")
    """
	@ivar: products of Place (relationships One Place to many Product)
	@type v: Array Product objects
    """
    staffs = MultipleJoin("Staff")
    """
	@ivar: staffs of Place (relationships One Place to many Staff)
	@type v: Array Staff objects
    """
    bills = MultipleJoin("Bill")
    """
	@ivar: bills of Place (relationships One Place to many Bill)
	@type v: Array Bill objects
    """
    stocks = MultipleJoin("Stock")
    """
	@ivar: stocks of Place (relationships One Place to many Stock)
	@type v: Array Stock objects
    """
    parkings = MultipleJoin("Parking")
    """
	@ivar: parkings of Place (relationships One Place to many Parking)
	@type v: Array Parking objects
    """
    def __str__(self):
	"""
	    Methode __str__ de l object Place
	
	    @return: company of Place
	    @rtype: String
	"""
        return self.company

Place.createTable(ifNotExists=True)

class Person(SQLObject):
    """
	Person Object (Personne)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    fname = StringCol(length=50, notNone=False, default=None)
    """
	@ivar: fname (firstname) of Person lenght(max): 50 null
	@type v: String
    """
    lname = StringCol(length=50, notNone=True)
    """
	@ivar: lname (lastname) of Person lenght(max): 50 not null
	@type v: String
    """
    status = StringCol(length=2, notNone=True)
    """
	@ivar: status of Person lenght(max): 2 not null
	@type v: String
    """
    address1 = StringCol(length=50, notNone=True)
    """
	@ivar: address1 (ligne 1) of Person lenght(max): 50 not null
	@type v: String
    """
    address2 = StringCol(length=50, notNone=False, default=None)
    """
	@ivar: address2 (ligne 2) of Person lenght(max): 50 null
	@type v: String
    """
    city = ForeignKey("City", cascade=False)
    """
	@ivar: city of Person (relationlships foreignkey) not null
	@type v: Object City
    """
    tel = StringCol(length=20, notNone=False, default=None)
    """
	@ivar: tel of Person lenght(max): 20 null
	@type v: String
    """
    fax = StringCol(length=20, notNone=False, default=None)
    """
	@ivar: fax of Person lenght(max): 20 null
	@type v: String
    """
    cell = StringCol(length=20, notNone=False, default=None)
    """
	@ivar: cell of Person lenght(max): 20 null
	@type v: String
    """
    email = StringCol(length=100, notNone=False, default=None)
    """
	@ivar: email of Person lenght(max): 100 null
	@type v: String
    """
    comment = StringCol(notNone=False, default=None)
    """
	@ivar: comment of Person null
	@type v: String
    """
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Person not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Person default : DateTime
	@type v: DateTime
    """
    residents = MultipleJoin("Resident")
    """
	@ivar: residents of Person (relationships One Person to many Resident)
	@type v: Array Resident objects
    """
    stays = MultipleJoin("Stay")
    """
	@ivar: stays of Person (relationships One Person to many Stay)
	@type v: Array Stay objects
    """
    bills = MultipleJoin("Bill")
    """
	@ivar: bills of Person (relationships One Person to many Stay)
	@type v: Array Stay objects
    """
    def __str__(self):
	"""
	    Methode __str__ de l object Person
	
	    @return: fname + lname of Person
	    @rtype: String
	"""
        return self.fname+" "+self.lname

Person.createTable(ifNotExists=True)

class Staff(SQLObject):
    """
	Staff Object (Employer)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    place = ForeignKey("Place", cascade=False)
    """
	@ivar: place of Staff (relationships foreignkey Place)
	@type v: Object Place
    """
    fname = StringCol(length=50, notNone=False, default=None)
    """
	@ivar: fname (firstname) of Staff lenght(max): 50 null
	@type v: String
    """
    lname = StringCol(length=50, notNone=True)
    """
	@ivar: lname (lastname) of Staff lenght(max): 50 not null
	@type v: String
    """
    mname = StringCol(length=3, notNone=True)
    """
	@ivar: mname (midlename) of Staff lenght(max): 3 not null
	@type v: String
    """
    username = StringCol(length=20, notNone=True)
    """
	@ivar: username of Staff lenght(max): 20 not null
	@type v: String
    """
    password = StringCol(length=20, notNone=True)
    """
	@ivar: password of Staff lenght(max): 20 not null
	@type v: String
    """
    status = StringCol(length=1, notNone=True)
    """
	@ivar: status of Staff lenght(max): 1 not null
	@type v: String
    """
    grade = StringCol(length=2, notNone=True, default="AD")
    """
	@ivar: grade of Staff lenght(max): 2 not null
	@type v: String
    """
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Staff not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Staff default : DateTime
	@type v: DateTime
    """
    timeSheetStaffs = MultipleJoin("TimeSheetStaff")
    """
	@ivar: timeSheetStaffs of Staff (relationships One Staff to many TimeSheetStaff)
	@type v: Array TimeSheetStaff objects
    """
    stocks = MultipleJoin("Stock")
    """
	@ivar: stocks of Staff (relationships One Staff to many Stock)
	@type v: Array Stock objects
    """
    invantorys = MultipleJoin("Invantory")
    """
	@ivar: invantorys of Staff (relationships One Staff to many Invantory)
	@type v: Array Invantory objects
    """
    requestByCleans = MultipleJoin("Cleaning")
    """
	@ivar: requestByCleans of Staff (relationships One Staff to many Cleaning)
	@type v: Array Cleaning objects
    """
    finishBys = MultipleJoin("Cleaning")
    """
	@ivar: finishBys of Staff (relationships One Staff to many Cleaning)
	@type v: Array Cleaning objects
    """
    checkBys = MultipleJoin("Cleaning")
    """
	@ivar: checkBys of Staff (relationships One Staff to many Cleaning)
	@type v: Array Cleaning objects
    """
    requestByTechs = MultipleJoin("Technical")
    """
	@ivar: requestByTechs of Staff (relationships One Staff to many Technical)
	@type v: Array Technical objects
    """
    answerBys = MultipleJoin("Technical")
    """
	@ivar: answerBys of Staff (relationships One Staff to many Technical)
	@type v: Array Technical objects
    """
    solvingBys = MultipleJoin("Technical")
    """
	@ivar: solvingBys of Staff (relationships One Staff to many Technical)
	@type v: Array Technical objects
    """
    checkInBys = MultipleJoin("Ocupancy")
    """
	@ivar: checkInBys of Staff (relationships One Staff to many Ocupancy)
	@type v: Array Ocupancy objects
    """
    checkOutBys = MultipleJoin("Ocupancy")
    """
	@ivar: checkOutBys of Staff (relationships One Staff to many Ocupancy)
	@type v: Array Ocupancy objects
    """
    invantoryInBys = MultipleJoin("Ocupancy")
    """
	@ivar: invantoryInBys of Staff (relationships One Staff to many Ocupancy)
	@type v: Array Ocupancy objects
    """
    invantoryOutBys = MultipleJoin("Ocupancy")
    """
	@ivar: checkIOutBys of Staff (relationships One Staff to many Ocupancy)
	@type v: Array Ocupancy objects
    """
    def __str__(self):
	"""
	    Methode __str__ de l object Staff
	
	    @return: lname + mname of Staff
	    @rtype: String
	"""
        return self.lname+"-"+self.mname

Staff.createTable(ifNotExists=True)

class TimeSheetStaff(SQLObject):
    """
	TimeSheetStaff Object (Feuuille d\'heure)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    staff = ForeignKey("Staff", cascade=True) 
    description = StringCol(length=50, notNone=True) 
    dateIn = DateTimeCol(notNone=True) 
    dateOut = DateTimeCol(notNone=False, default=None) 
    checked = StringCol(length=2, notNone=True, default="E") 
    notes = StringCol(notNone=False, default="") 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of TimeSheetStaff not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of TimeSheetStaff default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object TimeSheetStaff
	
	    @return: staff + dateIn of TimeSheetStaff
	    @rtype: String
	"""
        return str(self.staff)+"-"+str(self.dateIn)

TimeSheetStaff.createTable(ifNotExists=True)

class Discount(SQLObject):
    """
	Discount Object (Remise)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    code = StringCol(length=50, notNone=True, unique=True) 
    description = StringCol(length=50, notNone=True) 
    dateIn = DateTimeCol(default=DateTimeCol.now , notNone=True) 
    dateOut = DateTimeCol(notNone=True) 
    rate = DecimalCol(size=5, precision=2, default=0.00) 
    sum = DecimalCol(size=7, precision=2, default=0.00) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Discount not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Discount default : DateTime
	@type v: DateTime
    """
    stays = MultipleJoin("Stay")
    def __str__(self):
	"""
	    Methode __str__ de l object Discount
	
	    @return: code + description of Discount
	    @rtype: String
	"""
        return self.code+"-"+self.description

Discount.createTable(ifNotExists=True)

class Reference(SQLObject):
    """
	Reference Object
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    code = StringCol(length=20, notNone=True, unique=True) 
    category = StringCol(length=2, notNone=True, default="PR") 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Reference not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Reference default : DateTime
	@type v: DateTime
    """
    parkings = MultipleJoin("Parking")
    products = MultipleJoin("Product")
    services = MultipleJoin("Service")
    lineCatalogues = MultipleJoin("LineCatalogue")
    lineBills = MultipleJoin("LineBill")
    items = MultipleJoin("Item")    
    def __str__(self):
	"""
	    Methode __str__ de l object Reference
	
	    @return: code of Reference
	    @rtype: String
	"""
        return self.code

Reference.createTable(ifNotExists=True)

class ProductFamily(SQLObject):
    """
	ProductFamily Object (Famille de produit)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    code = StringCol(length=5, notNone=True, unique=True) 
    designation = StringCol(length=40, notNone=True) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of ProductFamily not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of ProductFamily default : DateTime
	@type v: DateTime
    """
    products = MultipleJoin("Product")
    def __str__(self):
	"""
	    Methode __str__ de l object ProductFamily
	
	    @return: designation of ProductFamily
	    @rtype: String
	"""
        return self.designation

ProductFamily.createTable(ifNotExists=True)

class ServiceFamily(SQLObject):
    """
	ServiceFamily Object (Famille de service)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    code = StringCol(length=5, notNone=True, unique=True) 
    designation = StringCol(length=40, notNone=True) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of ServiceFamily not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of ServiceFamily default : DateTime
	@type v: DateTime
    """
    services = MultipleJoin("Service")
    def __str__(self):
	"""
	    Methode __str__ de l object ServiceFamily
	
	    @return: designation of ServiceFamily
	    @rtype: String
	"""
        return self.designation

ServiceFamily.createTable(ifNotExists=True)

class Service(SQLObject):
    """
	Service Object
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    serviceFamily = ForeignKey("ServiceFamily", cascade=True, notNone=True) 
    place =  ForeignKey("Place", cascade=True, notNone=True) 
    reference = ForeignKey("Reference", cascade=True, notNone=False) 
    designation = StringCol(length=40, notNone=True) 
    description = StringCol(notNone=False) 
    checkIn = DateTimeCol(notNone=False) 
    checkOut = DateTimeCol(notNone=False)
    contact = StringCol(length=100, notNone=False) 
    notes = StringCol(notNone=False) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Service not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Service default : DateTime
	@type v: DateTime
    """
    serviceChoices = MultipleJoin("ServiceChoice")
    def __str__(self):
	"""
	    Methode __str__ de l object Service
	
	    @return: reference + designation of Service
	    @rtype: String
	"""
        return str(self.reference)+"-"+self.designation

Service.createTable(ifNotExists=True)

class Parking(SQLObject):
    """
	Parking Object
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    type = StringCol(length=2, notNone=True, default="E") 
    place = ForeignKey("Place", cascade=True, notNone=True) 
    reference = ForeignKey("Reference", cascade=True, notNone=True) 
    description = StringCol(length=40, notNone=True) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Parking not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Parking default : DateTime
	@type v: DateTime
    """
    parkingChoices = MultipleJoin("ParkingChoice")
    def __str__(self):
	"""
	    Methode __str__ de l object Parking
	
	    @return: reference + description of Parking
	    @rtype: String
	"""
        return str(self.reference)+"-"+self.description

Parking.createTable(ifNotExists=True)

class Product(SQLObject):
    """
	Product Object (Produit)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    productFamily = ForeignKey("ProductFamily", cascade=True, notNone=True) 
    place = ForeignKey("Place", cascade=True, notNone=True) 
    reference = ForeignKey("Reference", cascade=True, notNone=True) 
    designation = StringCol(length=40, notNone=True) 
    description = StringCol(notNone=False) 
    number = StringCol(length=10, default="0") 
    sleeps = IntCol(default=2) 
    area = IntCol(default=0) 
    floor = IntCol(default=0) 
    tel = StringCol(length=15, notNone=False) 
    status = StringCol(length=2, notNone=True, default="S") 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Product not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Product default : DateTime
	@type v: DateTime
    """
    productChoices = MultipleJoin("ProductChoice")
    productPhotos = MultipleJoin("ProductPhoto")
    cleanings = MultipleJoin("Cleaning")
    technicals = MultipleJoin("Technical")
    ocupancys = MultipleJoin("Ocupancy")
    productItems = MultipleJoin("ProductItem")
    def __str__(self):
	"""
	    Methode __str__ de l object Product
	
	    @return: reference + productFamily + number of Product
	    @rtype: String
	"""
        return str(self.reference)+"-"+str(self.productFamily)+"-"+self.number

Product.createTable(ifNotExists=True)

class ProductPhoto(SQLObject):
    """
	ProductPhoto Object (Photo des produits)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    product = ForeignKey("Product", cascade=True, notNone=True) 
    name = StringCol(length=40, notNone=True)
    img = StringCol(length=100, notNone=True) 
    comment = StringCol(length=100, notNone=False) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of ProductPhoto not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of ProductPhoto default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object ProductPhoto
	
	    @return: comment of ProductPhoto
	    @rtype: String
	"""
        return self.comment

ProductPhoto.createTable(ifNotExists=True)

class Stay(SQLObject):
    """
	Stay Object (Sejour)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    voucher = StringCol(length=20, notNone=True, unique=True) 
    contact = ForeignKey("Person", cascade=False, notNone=True) 
    checkIn = DateTimeCol(notNone=True) 
    checkOut = DateTimeCol(notNone=True) 
    discount = ForeignKey("Discount", cascade=False, notNone=False) 
    notes = StringCol(notNone=False) 
    status = StringCol(length=2, notNone=True, default="O") 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Stay not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Stay default : DateTime
	@type v: DateTime
    """
    productChoices = MultipleJoin("ProductChoice")
    parkingChoices = MultipleJoin("ParkinkChoice")
    serviceChoices = MultipleJoin("ServiceChoice")
    residents = MultipleJoin("Resident")
    ocupancys = MultipleJoin("Ocupancy")
    stayBills = MultipleJoin("StayBill")
    def __str__(self):
	"""
	    Methode __str__ de l object Stay
	
	    @return: contact of Stay
	    @rtype: String
	"""
        return str(self.contact)  

Stay.createTable(ifNotExists=True)

class StayVoucher(SQLObject):
    """
	StayVoucher Object (Numero de sejour)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    number = StringCol(notNone=True, unique=True) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of StayVoucher not null
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object StayVoucher
	
	    @return: number of StayVoucher
	    @rtype: String
	"""
        return self.number

StayVoucher.createTable(ifNotExists=True)

class ProductChoice(SQLObject):
    """
	ProductChoice Object (Produit choisis)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    stay = ForeignKey("Stay", cascade=True, notNone=True) 
    wish = ForeignKey("Product", cascade=False, notNone=True) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of ProductChoice not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of ProductChoice default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object ProductChoice
	
	    @return: wish of ProductChoice
	    @rtype: String
	"""
        return str(self.wish)

ProductChoice.createTable(ifNotExists=True)

class ParkingChoice(SQLObject):
    """
	ParkingChoice Object (Parking choisis)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    stay = ForeignKey("Stay", cascade=True, notNone=True) 
    type = StringCol(length=2, notNone=True, default="A") 
    wish = ForeignKey("Parking", cascade=False, notNone=False) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of ParkingChoice not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of ParkingChoice default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object ParkingChoice
	
	    @return: type of ParkingChoice
	    @rtype: String
	"""
        return self.type

ParkingChoice.createTable(ifNotExists=True)

class ServiceChoice(SQLObject):
    """
	ServiceChoice Object (Service choisis)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    stay = ForeignKey("Stay", cascade=True, notNone=True) 
    wish = ForeignKey("Service", cascade=False, notNone=True) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of ServiceChoice not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of ServiceChoice default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object ServiceChoice
	
	    @return: wish of ServiceChoice
	    @rtype: String
	"""
        return str(self.wish)

ServiceChoice.createTable(ifNotExists=True)

class Resident(SQLObject):
    """
	Resident Object
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    stay = ForeignKey("Stay", cascade=True, notNone=True) 
    person = ForeignKey("Person", cascade=False, notNone=True) 
    old = StringCol(length=2, notNone=True, default="A") 
    passport = StringCol(length=50, notNone=False) 
    pets = StringCol(length=2, notNone=True, default="NO") 
    notes = StringCol(notNone=False) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Resident not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Resident default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object Resident
	
	    @return: person of Resident
	    @rtype: String
	"""
        return str(self.person)

Resident.createTable(ifNotExists=True)

class Tax(SQLObject):
    """
	Tax Object (Taxe)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    country = ForeignKey("Country", cascade=False, notNone=True) 
    code = StringCol(length=5, notNone=False) 
    designation = StringCol(length=40, notNone=True) 
    rate = DecimalCol(size=5, precision=2, default=0.00) 
    dateIn = DateCol(notNone=True) 
    dateOut = DateCol(notNone=False, default=None) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Tax not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Tax default : DateTime
	@type v: DateTime
    """
    lineCatalogues = MultipleJoin("LineCatalogue")
    lineBills = MultipleJoin("LineBill")
    def __str__(self):
	"""
	    Methode __str__ de l object Tax
	
	    @return: rate of Tax
	    @rtype: String
	"""
        return str(self.rate)

Tax.createTable(ifNotExists=True)

class Catalogue(SQLObject):
    """
	Catalogue Object
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    name = StringCol(length=50, notNone=True, unique=True) 
    dateIn = DateCol(notNone=True) 
    dateOut = DateCol(notNone=False, default=None) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Catalogue not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Catalogue default : DateTime
	@type v: DateTime
    """
    lineCatalogues = MultipleJoin("LineCatalogue")
    def __str__(self):
	"""
	    Methode __str__ de l object Catalogue
	
	    @return: name of Catalogue
	    @rtype: String
	"""
        return self.name

Catalogue.createTable(ifNotExists=True)

class LineCatalogue(SQLObject):
    """
	LineCatalogue Object (Ligne du catalogue)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    catalogue = ForeignKey("Catalogue", cascade=True, notNone=True) 
    reference = ForeignKey("Reference", cascade=False, notNone=True) 
    description = StringCol(notNone=False) 
    price = DecimalCol(size=10, precision=2, default=0.00) 
    tax = ForeignKey("Tax", cascade=False, notNone=True) 
    unit = StringCol(length=2, notNone=True, default="UT") 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of LineCatalogue not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of LineCatalogue default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object LineCatalogue
	
	    @return: reference of LineCatalogue
	    @rtype: String
	"""
        return str(self.reference)

LineCatalogue.createTable(ifNotExists=True)

class Bill(SQLObject):
    """
	Bill Object (Piece de vente)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    date = DateCol(notNone=True) 
    reference = StringCol(length=20, notNone=True, unique=True) 
    sort = StringCol(length=2, notNone=True, default="C") 
    customer = ForeignKey("Person", cascade=False, notNone=True) 
    place = ForeignKey("Place", cascade=False, notNone=True) 
    dueDate = DateCol(notNone=True) 
    tHTPrice = DecimalCol(size=10, precision=2, default=0.00) 
    tTaxPrice = DecimalCol(size=10, precision=2, default=0.00) 
    tTCPrice = DecimalCol(size=10, precision=2, default=0.00) 
    notes = StringCol(length=150, notNone=False) 
    status = StringCol(length=2, notNone=True) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Bill not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Bill default : DateTime
	@type v: DateTime
    """
    lineBills = MultipleJoin("LineBill")
    paymentBills = MultipleJoin("PaymentBill")
    stayBills = MultipleJoin("StayBill")
    chasingUps = MultipleJoin("ChasingUp")
    stocks = MultipleJoin("Stock")
    def __str__(self):
	"""
	    Methode __str__ de l object Bill
	
	    @return: reference of Bill
	    @rtype: String
	"""
        return self.reference

Bill.createTable(ifNotExists=True)

class LineBill(SQLObject):
    """
	LineBill Object (Ligne de piece de vente)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    bill = ForeignKey("Bill", cascade=True, notNone=True) 
    line = IntCol(default=0) 
    reference = ForeignKey("Reference", cascade=False, notNone=False) 
    designation = StringCol(length=100, notNone=True) 
    price = DecimalCol(size=10, precision=2, default=0.00) 
    quantity = DecimalCol(size=10, precision=2, default=0.00)  
    totalPrice = DecimalCol(size=10, precision=2, default=0.00) 
    tax = ForeignKey("Tax", cascade=False, notNone=True) 
    priceInclusTax = DecimalCol(size=10, precision=2, default=0.00) 
    status = StringCol(length=2, notNone=True, default="C") 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of LineBill not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of LineBill default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object LineBill
	
	    @return: line of LineBill
	    @rtype: String
	"""
        return str(self.line)

LineBill.createTable(ifNotExists=True)

class NumberBill(SQLObject):
    """
	NumberBill Object (Numero de piece de vente)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    number = StringCol(notNone=True, unique=True) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of NumberBill not null
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object NumberBill
	
	    @return: number of NumberBill
	    @rtype: String
	"""
        return self.number

NumberBill.createTable(ifNotExists=True)

class PaymentBill(SQLObject):
    """
	PaymentBill Object (Facture payer)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    bill = ForeignKey("Bill", cascade=True, notNone=True) 
    line = IntCol(default=0) 
    date = DateCol(notNone=True) 
    designation = StringCol(length=2, notNone=True, default="R") 
    price = DecimalCol(size=10, precision=2, default=0.00) 
    mode = StringCol(length=2, notNone=True) 
    status = StringCol(length=2, notNone=True, default="EA") 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of PaymentBill not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of PaymentBill default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object PaymentBill
	
	    @return: line of PaymentBill
	    @rtype: String
	"""
        return str(self.line)

PaymentBill.createTable(ifNotExists=True)

class StayBill(SQLObject):
    """
	StayBill Object (Facture lier au sejour)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    bill = ForeignKey("Bill", cascade=False, notNone=True) 
    stay = ForeignKey("Stay", cascade=False, notNone=True) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of StayBill not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of StayBill default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object StayBill
	
	    @return: stay + bill of StayBill
	    @rtype: String
	"""
        return str(self.stay)+"/"+str(self.bill)

StayBill.createTable(ifNotExists=True)

class ChasingUp(SQLObject):
    """
	ChasingUp Object (Relance)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    bill = ForeignKey("Bill", cascade=True, notNone=True) 
    date = DateCol(notNone=True) 
    mode = StringCol(length=2, notNone=True, default="TE")
    notes = StringCol(notNone=False) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of ChasingUp not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of ChasingUp default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object ChasingUp
	
	    @return: bill + date of ChasingUp
	    @rtype: String
	"""
        return str(self.bill)+"-"+str(self.date)

ChasingUp.createTable(ifNotExists=True)

class Ocupancy(SQLObject):
    """
	Ocupancy Object (Ocupation)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    place = ForeignKey("Place", cascade=False, notNone=True) 
    stay = ForeignKey("Stay", cascade=False, notNone=True) 
    product = ForeignKey("Product", cascade=False, notNone=True) 
    checkIn = DateTimeCol(notNone=False) 
    checkOut = DateTimeCol(notNone=False) 
    checkInBy = ForeignKey("Staff", cascade=False, notNone=False) 
    checkOutBy = ForeignKey("Staff", cascade=False, notNone=False) 
    invantoryInBy = ForeignKey("Staff", cascade=False, notNone=False) 
    invantoryOutBy = ForeignKey("Staff", cascade=False, notNone=False) 
    notes = StringCol(notNone=False) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Ocupancy not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Ocupancy default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object Ocupancy
	
	    @return: stay of Ocupancy
	    @rtype: String
	"""
        return str(self.stay)

Ocupancy.createTable(ifNotExists=True)

class Cleaning(SQLObject):
    """
	Cleaning Object (Nettoyage)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    product = ForeignKey("Product", cascade=True, notNone=False) 
    designation = StringCol(length=50, notNone=True) 
    request = DateTimeCol(notNone=True) 
    finish = DateTimeCol(notNone=False) 
    checked = DateTimeCol(notNone=False) 
    status = StringCol(length=2, notNone=True, default="EA") 
    notes = StringCol(notNone=False) 
    requestByClean = ForeignKey("Staff", cascade=False, notNone=True) 
    finishBy = ForeignKey("Staff", cascade=False, notNone=False) 
    checkBy = ForeignKey("Staff", cascade=False, notNone=False) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Cleaning not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Cleaning default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object Cleaning
	
	    @return: request + designation of Cleaning
	    @rtype: String
	"""
        return str(self.request)+"-"+self.designation

Cleaning.createTable(ifNotExists=True)

class Technical(SQLObject):
    """
	Technical Object (Intervention technique)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    product = ForeignKey("Product", cascade=True, notNone=False) 
    designation = StringCol(length=50, notNone=True) 
    request = DateTimeCol(notNone=True) 
    answer = DateTimeCol(notNone=False) 
    solving = DateTimeCol(notNone=False) 
    status = StringCol(length=2, notNone=True, default="EA") 
    notes = StringCol(notNone=False) 
    requestByTech = ForeignKey("Staff", cascade=False, notNone=True) 
    answerBy = ForeignKey("Staff", cascade=False, notNone=False) 
    solvingBy = ForeignKey("Staff", cascade=False, notNone=False) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Technical not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Technical default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object Technical
	
	    @return: request + designation of Technical
	    @rtype: String
	"""
        return str(self.request)+"-"+self.designation

Technical.createTable(ifNotExists=True)

class ItemFamily(SQLObject):
    """
	ItemFamily Object (Famille d article)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    code = StringCol(length=5, notNone=True, unique=True) 
    designation = StringCol(length=40, notNone=True) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of ItemFamily not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of ItemFamily default : DateTime
	@type v: DateTime
    """
    items = MultipleJoin("Item")
    def __str__(self):
	"""
	    Methode __str__ de l object ItemFamily
	
	    @return: designation of ItemFamily
	    @rtype: String
	"""
        return self.designation

ItemFamily.createTable(ifNotExists=True)

class Item(SQLObject):
    """
	Item Object (Article)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    itemFamily = ForeignKey("ItemFamily", cascade=True, notNone=True) 
    reference = ForeignKey("Reference", cascade=False, notNone=True) 
    designation = StringCol(length=40, notNone=True) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Item not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Item default : DateTime
	@type v: DateTime
    """
    productItems = MultipleJoin("ProductItem")
    stocks = MultipleJoin("Stock")
    def __str__(self):
	"""
	    Methode __str__ de l object Item
	
	    @return: designation of Item
	    @rtype: String
	"""
        return self.designation

Item.createTable(ifNotExists=True)

class ProductItem(SQLObject):
    """
	ProductItem Object (Article d un produit)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    product = ForeignKey("Product", cascade=True, notNone=True) 
    item = ForeignKey("Item", cascade=True, notNone=True) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of ProductItem not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of ProductItem default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object ProductItem
	
	    @return: product + item of ProductItem
	    @rtype: String
	"""
        return str(self.product)+"-"+str(self.item)

ProductItem.createTable(ifNotExists=True)

class Stock(SQLObject):
    """
	Stock Object
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    place = ForeignKey("Place", cascade=False, notNone=True) 
    item = ForeignKey("Item", cascade=False, notNone=True) 
    status = StringCol(length=2, notNone=True, default="ER") 
    bill = ForeignKey("Bill", cascade=False, notNone=False) 
    deliveryDate = DateTimeCol(notNone=False) 
    deliveryQuantity = DecimalCol(size=10, precision=2, default=0.00) 
    stockQuantity = DecimalCol(size=10, precision=2, default=0.00) 
    alertQuantity = DecimalCol(size=10, precision=2, default=0.00) 
    checkBy = ForeignKey("Staff", cascade=False, notNone=True) 
    notes = StringCol(notNone=False) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Stock not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Stock default : DateTime
	@type v: DateTime
    """
    inventorys = MultipleJoin("Invantory")
    def __str__(self):
	"""
	    Methode __str__ de l object Stock
	
	    @return: item + status + stockquantity of Stock
	    @rtype: String
	"""
        return str(self.item)+"-"+self.status+"-"+str(self.stockquantity)

Stock.createTable(ifNotExists=True)

class Invantory(SQLObject):
    """
	Invantory Object (Inventaire)
	
	@param SQLObject: Heritage de ORM SQLObject
    """
    stock = ForeignKey("Stock", cascade=True, notNone=True) 
    date = DateCol(notNone=True) 
    checkQuantity = DecimalCol(size=10, precision=2, default=0.00) 
    differenceQuantity = DecimalCol(size=10, precision=2, default=0.00) 
    notes = StringCol(notNone=False) 
    checkBy = ForeignKey("Staff", cascade=False, notNone=True) 
    createDate = DateTimeCol(notNone=True)
    """
	@ivar: createDate of Invantory not null
	@type v: DateTime
    """
    modifyDate = DateTimeCol(default=DateTimeCol.now)
    """
	@ivar: modifyDate of Invantory default : DateTime
	@type v: DateTime
    """
    def __str__(self):
	"""
	    Methode __str__ de l object Invantory
	
	    @return: stock + quantity of Invantory
	    @rtype: String
	"""
        return str(self.stock)+"-"+str(self.quantity)

Invantory.createTable(ifNotExists=True)